﻿#region zh-CHS 2006 - 2010 DemoSoft 团队 | en 2006-2010 DemoSoft Team

//     NOTES
// ---------------
//
// This file is a part of the MMOSE(Massively Multiplayer Online Server Engine) for .NET.
//
//                              2006-2010 DemoSoft Team
//
//
// First Version : by H.Q.Cai - mailto:caihuanqing@hotmail.com

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published
 *   by the Free Software Foundation; either version 2.1 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

#region zh-CHS 包含名字空间 | en Include namespace
using System;
using System.Threading;
using Demo.Mmose.Core.Util;
#endregion

namespace Demo.Mmose.Core.Common.Atom
{
    /// <summary>
    /// 
    /// </summary>
    public class AtomicInt : IAtomOperator<int>, IComparable, IComparable<AtomicInt>
    {
        #region zh-CHS 构造和初始化和清理 | en Constructors and Initializers and Dispose
        /// <summary>
        /// 
        /// </summary>
        private AtomicInt()
        {
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="atomicInt"></param>
        private AtomicInt( int atomicInt )
        {
            m_AtomicInt = atomicInt;
        }
        #endregion

        #region zh-CHS 属性 | en Properties
        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private int m_AtomicInt = 0;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public int Value
        {
            get { return m_AtomicInt; }
        }
        #endregion

        #region zh-CHS 接口实现 | en Interface Implementation
        /// <summary>
        /// 以原子方式将给定值与当前值相加。
        /// </summary>
        /// <param name="addValue"></param>
        /// <returns></returns>
        public void Add( int addValue )
        {
            Interlocked.Add( ref m_AtomicInt, addValue );
        }

        /// <summary>
        /// 以原子方式将给定值与当前值相减。
        /// </summary>
        /// <param name="subtractValue"></param>
        /// <returns></returns>
        public void Subtract( int subtractValue )
        {
            Interlocked.Add( ref m_AtomicInt, - subtractValue );
        }

        /// <summary>
        /// 以原子方式将给定值与当前值相乘。
        /// </summary>
        /// <param name="multiplyValue"></param>
        /// <returns></returns>
        public void Multiply( int multiplyValue )
        {
            int oldAtomicInt;
            int newAtomicInt;

            do
            {
                oldAtomicInt = m_AtomicInt;
                newAtomicInt = m_AtomicInt * multiplyValue;

            } while ( Interlocked.CompareExchange( ref m_AtomicInt, newAtomicInt, oldAtomicInt ) != oldAtomicInt );
        }

        /// <summary>
        /// 以原子方式将给定值与当前值相除。
        /// </summary>
        /// <param name="divideValue"></param>
        /// <returns></returns>
        public void Divide( int divideValue )
        {
            int oldAtomicInt;
            int newAtomicInt;

            do
            {
                oldAtomicInt = m_AtomicInt;
                newAtomicInt = m_AtomicInt / divideValue;

            } while ( Interlocked.CompareExchange( ref m_AtomicInt, newAtomicInt, oldAtomicInt ) != oldAtomicInt );
        }

        /// <summary>
        /// 以原子方式设置为给定值。
        /// </summary>
        /// <param name="assignmentValue"></param>
        /// <returns></returns>
        public void Assignment( int assignmentValue )
        {
            int oldAtomicInt;
            int newAtomicInt;

            do
            {
                oldAtomicInt = m_AtomicInt;
                newAtomicInt = assignmentValue;

            } while ( Interlocked.CompareExchange( ref m_AtomicInt, newAtomicInt, oldAtomicInt ) != oldAtomicInt );
        }

        /// <summary>
        /// 如果当前值 == 预期值，则以原子方式将该值设置为给定的更新值。
        /// </summary>
        /// <param name="setValue"></param>
        /// <param name="compareValue"></param>
        /// <returns></returns>
        public bool CompareExchange( int setValue, int compareValue )
        {
            return Interlocked.CompareExchange( ref m_AtomicInt, setValue, compareValue ) == compareValue;
        }

        /// <summary>
        /// 以原子方式将当前值减 1 ( -- )
        /// </summary>
        /// <returns></returns>
        public void Decrement()
        {
            Interlocked.Decrement( ref m_AtomicInt );
        }

        /// <summary>
        /// 以原子方式将当前值加 1 ( ++ )
        /// </summary>
        /// <returns></returns>
        public void Increment()
        {
            Interlocked.Increment( ref m_AtomicInt );
        }

        /// <summary>
        /// 以原子方式将当前值左移 ( << )
        /// </summary>
        /// <returns></returns>
        public void LeftShift( int leftShift )
        {
            int oldAtomicInt;
            int newAtomicInt;

            do
            {
                oldAtomicInt = m_AtomicInt;
                newAtomicInt = m_AtomicInt << leftShift;

            } while ( Interlocked.CompareExchange( ref m_AtomicInt, newAtomicInt, oldAtomicInt ) != oldAtomicInt );
        }

        /// <summary>
        /// 以原子方式将当前值右移 ( >> )
        /// </summary>
        /// <returns></returns>
        public void RightShift( int rightShift )
        {
            int oldAtomicInt;
            int newAtomicInt;

            do
            {
                oldAtomicInt = m_AtomicInt;
                newAtomicInt = m_AtomicInt >> rightShift;

            } while ( Interlocked.CompareExchange( ref m_AtomicInt, newAtomicInt, oldAtomicInt ) != oldAtomicInt );
        }

        /// <summary>
        /// 以原子方式将当前值求正(一元操作) ( + )
        /// </summary>
        /// <param name="addValue"></param>
        /// <returns></returns>
        public void Plus()
        {
            int oldAtomicInt;
            int newAtomicInt;

            do
            {
                oldAtomicInt = m_AtomicInt;
                newAtomicInt = +m_AtomicInt;

            } while ( Interlocked.CompareExchange( ref m_AtomicInt, newAtomicInt, oldAtomicInt ) != oldAtomicInt );
        }

        /// <summary>
        /// 以原子方式将当前值求负(一元操作) ( - )
        /// </summary>
        /// <param name="addValue"></param>
        /// <returns></returns>
        public void Minus()
        {
            int oldAtomicInt;
            int newAtomicInt;

            do
            {
                oldAtomicInt = m_AtomicInt;
                newAtomicInt = -m_AtomicInt;

            } while ( Interlocked.CompareExchange( ref m_AtomicInt, newAtomicInt, oldAtomicInt ) != oldAtomicInt );
        }

        /// <summary>
        /// 以原子方式将当前值取反(一元操作) ( ! )
        /// </summary>
        /// <param name="addValue"></param>
        /// <returns></returns>
        public void Invert()
        {
            throw new NotSupportedException();
        }

        /// <summary>
        /// 以原子方式将当前值求补 ( ~ )
        /// </summary>
        /// <returns></returns>
        public void OneComplement()
        {
            int oldAtomicInt;
            int newAtomicInt;

            do
            {
                oldAtomicInt = m_AtomicInt;
                newAtomicInt = ~m_AtomicInt;

            } while ( Interlocked.CompareExchange( ref m_AtomicInt, newAtomicInt, oldAtomicInt ) != oldAtomicInt );
        }

        /// <summary>
        /// 以原子方式将当前值按位与 ( &= )
        /// </summary>
        /// <returns></returns>
        public void BitwiseAND( int bitwiseAnd )
        {
            int oldAtomicInt;
            int newAtomicInt;

            do
            {
                oldAtomicInt = m_AtomicInt;
                newAtomicInt = m_AtomicInt & bitwiseAnd;

            } while ( Interlocked.CompareExchange( ref m_AtomicInt, newAtomicInt, oldAtomicInt ) != oldAtomicInt );
        }

        /// <summary>
        /// 以原子方式将当前值按位或 ( |= )
        /// </summary>
        /// <returns></returns>
        public void BitwiseInclusiveOR( int inclusiveOR )
        {
            int oldAtomicInt;
            int newAtomicInt;

            do
            {
                oldAtomicInt = m_AtomicInt;
                newAtomicInt = m_AtomicInt | inclusiveOR;

            } while ( Interlocked.CompareExchange( ref m_AtomicInt, newAtomicInt, oldAtomicInt ) != oldAtomicInt );
        }

        /// <summary>
        /// 以原子方式将当前值按位异或 ( ^= )
        /// </summary>
        /// <returns></returns>
        public void BitwiseExclusiveOR( int exclusiveOR )
        {
            int oldAtomicInt;
            int newAtomicInt;

            do
            {
                oldAtomicInt = m_AtomicInt;
                newAtomicInt = m_AtomicInt ^ exclusiveOR;

            } while ( Interlocked.CompareExchange( ref m_AtomicInt, newAtomicInt, oldAtomicInt ) != oldAtomicInt );
        }
        #endregion

        #region zh-CHS 共有委托 | en Public Delegate
        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private EventHandler<UpdatingValue<int>> m_EventUpdatingValue;
        /// <summary>
        /// 
        /// </summary>
        private SpinLock m_LockEventUpdating = new SpinLock();
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public event EventHandler<UpdatingValue<int>> UpdatingValue
        {
            add
            {
                SpinLockEx.ReliableEnter( ref m_LockEventUpdating );
                try
                {
                    m_EventUpdatingValue += value;
                }
                finally
                {
                    m_LockEventUpdating.Exit();
                }
            }
            remove
            {
                SpinLockEx.ReliableEnter( ref m_LockEventUpdating );
                try
                {
                    m_EventUpdatingValue -= value;
                }
                finally
                {
                    m_LockEventUpdating.Exit();
                }
            }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private EventHandler<UpdatedValue<int>> m_EventUpdatedValue;
        /// <summary>
        /// 
        /// </summary>
        private SpinLock m_LockEventUpdated = new SpinLock();
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public event EventHandler<UpdatedValue<int>> UpdatedValue
        {
            add
            {
                SpinLockEx.ReliableEnter( ref m_LockEventUpdated );
                try
                {
                    m_EventUpdatedValue += value;
                }
                finally
                {
                    m_LockEventUpdated.Exit();
                }
            }
            remove
            {
                SpinLockEx.ReliableEnter( ref m_LockEventUpdated );
                try
                {
                    m_EventUpdatedValue -= value;
                }
                finally
                {
                    m_LockEventUpdated.Exit();
                }
            }
        }
        #endregion

        #region zh-CHS 方法 | en Method
        /// <summary>
        /// 将当前值左移 ( << )，并返回左移后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <param name="atomicIntB"></param>
        /// <returns></returns>
        public static AtomicInt operator >>( AtomicInt atomicIntA, int atomicIntB )
        {
            return new AtomicInt( atomicIntA.m_AtomicInt >> atomicIntB );
        }

        /// <summary>
        /// 将当前值右移 ( >> )，并返回右移后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <param name="atomicIntB"></param>
        /// <returns></returns>
        public static AtomicInt operator <<( AtomicInt atomicIntA, int atomicIntB )
        {
            return new AtomicInt( atomicIntA.m_AtomicInt << atomicIntB );
        }

        /// <summary>
        /// 将给定值与当前值相加，并返回相加后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <param name="atomicIntB"></param>
        /// <returns></returns>
        public static AtomicInt operator +( AtomicInt atomicIntA, int atomicIntB )
        {
            return new AtomicInt( atomicIntA.m_AtomicInt + atomicIntB );
        }

        /// <summary>
        /// 将给定值与当前值相加，并返回相加后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <param name="atomicIntB"></param>
        /// <returns></returns>
        public static AtomicInt operator +( AtomicInt atomicIntA, AtomicInt atomicIntB )
        {
            return new AtomicInt( atomicIntA.m_AtomicInt + atomicIntB.m_AtomicInt );
        }

        /// <summary>
        /// 将给定值与当前值相减，并返回相减后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <param name="atomicIntB"></param>
        /// <returns></returns>
        public static AtomicInt operator -( AtomicInt atomicIntA, int atomicIntB )
        {
            return new AtomicInt( atomicIntA.m_AtomicInt - atomicIntB );
        }

        /// <summary>
        /// 将给定值与当前值相减，并返回相减后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <param name="atomicIntB"></param>
        /// <returns></returns>
        public static AtomicInt operator -( AtomicInt atomicIntA, AtomicInt atomicIntB )
        {
            return new AtomicInt( atomicIntA.m_AtomicInt - atomicIntB.m_AtomicInt );
        }

        /// <summary>
        /// 将给定值与当前值相乘，并返回相乘后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <param name="atomicIntB"></param>
        /// <returns></returns>
        public static AtomicInt operator *( AtomicInt atomicIntA, int atomicIntB )
        {
            return new AtomicInt( atomicIntA.m_AtomicInt * atomicIntB );
        }

        /// <summary>
        /// 将给定值与当前值相乘，并返回相乘后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <param name="atomicIntB"></param>
        /// <returns></returns>
        public static AtomicInt operator *( AtomicInt atomicIntA, AtomicInt atomicIntB )
        {
            return new AtomicInt( atomicIntA.m_AtomicInt * atomicIntB.m_AtomicInt );
        }

        /// <summary>
        /// 将当前值与给定值相除，并返回相除后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <param name="atomicIntB"></param>
        /// <returns></returns>
        public static AtomicInt operator /( AtomicInt atomicIntA, int atomicIntB )
        {
            return new AtomicInt( atomicIntA.m_AtomicInt / atomicIntB );
        }

        /// <summary>
        /// 将当前值与给定值相除，并返回相除后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <param name="atomicIntB"></param>
        /// <returns></returns>
        public static AtomicInt operator /( AtomicInt atomicIntA, AtomicInt atomicIntB )
        {
            return new AtomicInt( atomicIntA.m_AtomicInt / atomicIntB.m_AtomicInt );
        }

        /// <summary>
        /// 将当前值与给定值相模，并返回相模后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <param name="atomicIntB"></param>
        /// <returns></returns>
        public static AtomicInt operator %( AtomicInt atomicIntA, int atomicIntB )
        {
            return new AtomicInt( atomicIntA.m_AtomicInt % atomicIntB );
        }

        /// <summary>
        /// 将当前值与给定值相模，并返回相模后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <param name="atomicIntB"></param>
        /// <returns></returns>
        public static AtomicInt operator %( AtomicInt atomicIntA, AtomicInt atomicIntB )
        {
            return new AtomicInt( atomicIntA.m_AtomicInt % atomicIntB.m_AtomicInt );
        }

        /// <summary>
        /// 将当前值与给定值相与，并返回相与后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <param name="atomicIntB"></param>
        /// <returns></returns>
        public static AtomicInt operator &( AtomicInt atomicIntA, int atomicIntB )
        {
            return new AtomicInt( atomicIntA.m_AtomicInt & atomicIntB );
        }

        /// <summary>
        /// 将当前值与给定值相与，并返回相与后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <param name="atomicIntB"></param>
        /// <returns></returns>
        public static AtomicInt operator &( AtomicInt atomicIntA, AtomicInt atomicIntB )
        {
            return new AtomicInt( atomicIntA.m_AtomicInt & atomicIntB.m_AtomicInt );
        }

        /// <summary>
        /// 将当前值与给定值相或，并返回相或后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <param name="atomicIntB"></param>
        /// <returns></returns>
        public static AtomicInt operator |( AtomicInt atomicIntA, int atomicIntB )
        {
            return new AtomicInt( atomicIntA.m_AtomicInt | atomicIntB );
        }

        /// <summary>
        /// 将当前值与给定值相或，并返回相或后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <param name="atomicIntB"></param>
        /// <returns></returns>
        public static AtomicInt operator |( AtomicInt atomicIntA, AtomicInt atomicIntB )
        {
            return new AtomicInt( atomicIntA.m_AtomicInt | atomicIntB.m_AtomicInt );
        }

        /// <summary>
        /// 将当前值与给定值相异或，并返回相异或后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <param name="atomicIntB"></param>
        /// <returns></returns>
        public static AtomicInt operator ^( AtomicInt atomicIntA, int atomicIntB )
        {
            return new AtomicInt( atomicIntA.m_AtomicInt ^ atomicIntB );
        }

        /// <summary>
        /// 将当前值与给定值相异或，并返回相异或后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <param name="atomicIntB"></param>
        /// <returns></returns>
        public static AtomicInt operator ^( AtomicInt atomicIntA, AtomicInt atomicIntB )
        {
            return new AtomicInt( atomicIntA.m_AtomicInt ^ atomicIntB.m_AtomicInt );
        }

        /// <summary>
        /// 将当前值求正，并返回求正后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <returns></returns>
        public static AtomicInt operator +( AtomicInt atomicInt )
        {
            return new AtomicInt( + atomicInt.m_AtomicInt );
        }

        /// <summary>
        /// 将当前值求负，并返回求负后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <returns></returns>
        public static AtomicInt operator -( AtomicInt atomicInt )
        {
            return new AtomicInt( - atomicInt.m_AtomicInt );
        }

        /// <summary>
        /// 将当前值求补，并返回求补后的数据
        /// </summary>
        /// <param name="atomicIntA"></param>
        /// <returns></returns>
        public static AtomicInt operator ~( AtomicInt atomicInt )
        {
            return new AtomicInt( ~ atomicInt.m_AtomicInt );
        }

        /// <summary>
        /// 以原子方式将当前值加 1 ( ++ )
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static AtomicInt operator ++( AtomicInt atomicInt )
        {
            atomicInt.Increment();

            return atomicInt;
        }

        /// <summary>
        /// 以原子方式将当前值减 1 ( -- )
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static AtomicInt operator --( AtomicInt atomicInt )
        {
            atomicInt.Decrement();

            return atomicInt;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator ==( AtomicInt atomicIntA, AtomicInt atomicIntB )
        {
            return atomicIntA.m_AtomicInt == atomicIntB.m_AtomicInt;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator ==( AtomicInt atomicIntA, int atomicIntB )
        {
            return atomicIntA.m_AtomicInt == atomicIntB;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator !=( AtomicInt atomicIntA, AtomicInt atomicIntB )
        {
            return atomicIntA.m_AtomicInt != atomicIntB.m_AtomicInt;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator !=( AtomicInt atomicIntA, int atomicIntB )
        {
            return atomicIntA.m_AtomicInt != atomicIntB;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator <( AtomicInt atomicIntA, AtomicInt atomicIntB )
        {
            return atomicIntA.m_AtomicInt < atomicIntB.m_AtomicInt;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator <( AtomicInt atomicIntA, int atomicIntB )
        {
            return atomicIntA.m_AtomicInt < atomicIntB;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator >( AtomicInt atomicIntA, AtomicInt atomicIntB )
        {
            return atomicIntA.m_AtomicInt > atomicIntB.m_AtomicInt;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator >( AtomicInt atomicIntA, int atomicIntB )
        {
            return atomicIntA.m_AtomicInt > atomicIntB;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator <=( AtomicInt atomicIntA, AtomicInt atomicIntB )
        {
            return atomicIntA.m_AtomicInt <= atomicIntB.m_AtomicInt;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator <=( AtomicInt atomicIntA, int atomicIntB )
        {
            return atomicIntA.m_AtomicInt <= atomicIntB;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator >=( AtomicInt atomicIntA, AtomicInt atomicIntB )
        {
            return atomicIntA.m_AtomicInt >= atomicIntB.m_AtomicInt;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator >=( AtomicInt atomicIntA, int atomicIntB )
        {
            return atomicIntA.m_AtomicInt >= atomicIntB;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="iSerial"></param>
        /// <returns></returns>
        public static explicit operator int( AtomicInt atomicInt )
        {
            return atomicInt.m_AtomicInt;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="atomicInt"></param>
        /// <returns></returns>
        public static implicit operator AtomicInt( int atomicInt )
        {
            return new AtomicInt( atomicInt );
        }
        #endregion

        #region zh-CHS 方法覆盖 | en Method Overrides
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return m_AtomicInt.ToString();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            return m_AtomicInt.GetHashCode();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="xObject"></param>
        /// <returns></returns>
        public override bool Equals( object xObject )
        {
            AtomicInt atomicInt = xObject as AtomicInt;
            if ( atomicInt == null )
                return false;

            return atomicInt.m_AtomicInt == m_AtomicInt;
        }
        #endregion

        #region zh-CHS 接口实现 | en Interface Implementation
        /// <summary>
        /// 
        /// </summary>
        /// <param name="otherAtomicInt"></param>
        /// <returns></returns>
        public int CompareTo( AtomicInt otherAtomicInt )
        {
            return m_AtomicInt.CompareTo( otherAtomicInt.m_AtomicInt );
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="otherObject"></param>
        /// <returns></returns>
        public int CompareTo( object otherObject )
        {
            AtomicInt atomicInt = otherObject as AtomicInt;
            if ( atomicInt == null )
                return 1;
            else
                return CompareTo( atomicInt );
        }
        #endregion
    }
}
#endregion